package com.terren.spider.db.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.terren.spider.db.basic.BasicServiceSupportImpl;
import com.terren.spider.db.service.AppXhsService;
import com.terren.spider.entity.biz.DetailXhs;
import com.terren.spider.entity.biz.XhsKeyboardSearch;
import com.terren.spider.entity.biz.XhsUserDetail;
import com.terren.spider.entity.core.XhsVIPUser;
import com.terren.spider.util.common.LogUtil;

@Service("appXhsService")
public class AppXhsServiceImpl extends BasicServiceSupportImpl implements AppXhsService {
	private final String SQL_MAPPER = "appXhsMapper.";

	@Override
	public void addDetailXhs(List<DetailXhs> items) throws Exception {
		try {
			basicDao.save(SQL_MAPPER + "addDetailXhs", items);
		} catch (Exception e) {
			e.printStackTrace();
			LogUtil.logger.error("添加数据时出错，方法名为addDetailXhs，错误信息为: {}");
		}

	}

	@Override
	public void saveXhsUserDetail(List<XhsUserDetail> items) throws Exception {
		try {
			basicDao.save(SQL_MAPPER + "saveXhsUserDetail", items);
		} catch (Exception e) {
			e.printStackTrace();
			LogUtil.logger.error("添加数据时出错，方法名为saveXhsUserDetail，错误信息为: {}");
		}

	}

	@Override
	public List<String> getXhsUserId() throws Exception {
		return basicDao.findForList(SQL_MAPPER + "getXhsUserId", null);
	}

	@Override
	public List<XhsUserDetail> getXhsUserDetailList() throws Exception {
		return basicDao.findForList(SQL_MAPPER + "getXhsUserDetailList", null);
	}

	@Override
	public List<XhsKeyboardSearch> getXhsKeyboardSearchList() throws Exception {
		return basicDao.findForList(SQL_MAPPER + "getXhsKeyboardSearchList", null);
	}

	@Override
	public void updateProgressStatus(List<XhsVIPUser> users) throws Exception {
		// TODO Auto-generated method stub
		basicDao.save(SQL_MAPPER + "updateProgressStatus", users);
	}

	@Override
	public void updateDoneStatus(List<XhsVIPUser> users) throws Exception {
		// TODO Auto-generated method stub
		basicDao.save(SQL_MAPPER + "updateDoneStatus", users);
	}

	@Override
	public List<XhsVIPUser> getAllXhsVIPUser(XhsVIPUser param) throws Exception {
		// TODO Auto-generated method stub
		return basicDao.findForList(SQL_MAPPER + "getAllXhsVIPUser", param);
	}

	@Override
	public void updateFetchtimes(List<XhsVIPUser> users) throws Exception {
		// TODO Auto-generated method stub
		basicDao.save(SQL_MAPPER + "updateFetchtimes", users);
	}

}
